package com.ruitu.health_1.ui;

import android.content.Context;
import android.graphics.Rect;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.ruitu.arad.base.BaseActivity;
import com.ruitu.arad.base.base_list.ListBaseAdapter;
import com.ruitu.arad.base.base_list.SuperViewHolder;
import com.ruitu.health_1.R;
import com.ruitu.router_module.AppHolder;

import java.util.ArrayList;
import java.util.List;

public class ActionActivity extends BaseActivity {

    @Override
    protected int getLayoutRes() {
        return R.layout.activity_action;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

    }

    private RecyclerView recyclerView;

    private List<String> data = new ArrayList<>();
    private DataAdapter adapter;
    private TextView tv_gold;

    @Override
    protected void initViews() {
        super.initViews();
        setHeadTitle("金币领取");
        recyclerView = findViewById(R.id.recyclerview);
        tv_gold = findViewById(R.id.tv_gold);
        recyclerView.setLayoutManager(new LinearLayoutManager(this));
        adapter = new DataAdapter(this);
        recyclerView.setAdapter(adapter);
        recyclerView.addItemDecoration(new RecyclerView.ItemDecoration() {
            @Override
            public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
                super.getItemOffsets(outRect, view, parent, state);
                outRect.bottom = 10;
            }
        });
        data.add("签到");
        data.add("阅读资讯");
        data.add("发表帖子");
        data.add("发表评论");
        data.add("分享内容");
        adapter.setDataList(data);
        tv_gold.setText(AppHolder.instance().getUser().getWallet().getBuyPoint() + "  金币");
    }

    class DataAdapter extends ListBaseAdapter<String> {

        public DataAdapter(Context context) {
            super(context);
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_task;
        }

        @Override
        public void onBindItemHolder(SuperViewHolder holder, int position) {
            TextView tv_task_name = holder.getView(R.id.tv_task_name);
            tv_task_name.setText(mDataList.get(position));
        }

    }
}
